package com.zhongkai.app.controller;

import com.zhongkai.app.service.AnomalyListService;
import com.zhongkai.model.utils.ZhongkaiResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class AnomalyListController {

    @Autowired
    private AnomalyListService anomalyListService;


    /***
     * 维修用户任务列表
     * @param wx_uuid 维修用户uuid
     *
     * */
    @RequestMapping(value = "/weixiu/task_list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult unitDate(String wx_uuid,  @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0")Integer rows) {

        ZhongkaiResult result = anomalyListService.anomalyList(wx_uuid,page,rows);

        return result;
    }




    /***
     * 添加历史
     * @param wx_uuid 维修用户uuid
     *
     * */
    @RequestMapping(value = "/weixiu/mange_list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult userMangeList(String wx_uuid,  @RequestParam(defaultValue = "0") Integer page, @RequestParam(defaultValue = "0")Integer rows) {

        ZhongkaiResult result = anomalyListService.userMangeList(wx_uuid,page,rows);

        return result;
    }




    /***
     * 修改签名
     * @param wx_uuid 维修用户uuid
     *
     * */
    @RequestMapping(value = "/weixiu/updata_sign", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult updataSign(String wx_uuid,String sign) {

        ZhongkaiResult result = null;
        try {
            result = anomalyListService.updataSign(wx_uuid,sign);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"修改失败");
        }

        return result;
    }



    /***
     * 修改昵称
     * @param wx_uuid 维修用户uuid
     *
     * */
    @RequestMapping(value = "/weixiu/updata_name", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult updataName(String wx_uuid,String name) {

        ZhongkaiResult result = null;
        try {
            result = anomalyListService.updataName(wx_uuid,name);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"修改失败");
        }

        return result;
    }





    /***
     * 获取用户信息
     * @param wx_uuid 维修用户uuid
     *
     * */
    @RequestMapping(value = "/weixiu/get_user_data", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult getUserData(String wx_uuid) {

        ZhongkaiResult result = null;
        try {
            result = anomalyListService.getUserData(wx_uuid);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"获取失败");
        }

        return result;
    }


    /***
     * 获取用户信息
     * @param wx_uuid 维修用户uuid
     * @param phone 手机号
     * @param code 验证码
     * */
    @RequestMapping(value = "/weixiu/updata_phone", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult updataPhoen(String wx_uuid,String phone,String code) {

        ZhongkaiResult result = null;
        try {
            result = anomalyListService.updataPhoen(wx_uuid,phone,code);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"获取失败");
        }

        return result;
    }

    /***
     * 修改密码
     * @param wx_uuid 维修用户uuid
     * @param code 验证码
     * @param pass 新密码
     * @param count 方式 1密码  2 验证码
     *
     * */
    @RequestMapping(value = "/weixiu/updata_pass", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult updataPass(String wx_uuid,String code,String pass,String count) {

        ZhongkaiResult result = null;
        try {
            result = anomalyListService.updataPass(wx_uuid,code,pass,count);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"获取失败");
        }

        return result;
    }


    /***
     * 验证密码
     * @param wx_uuid 维修用户uuid
     * @param pass 密码
     *
     * */
    @RequestMapping(value = "/weixiu/ver_pass", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult verifyPass(String wx_uuid,String pass) {

        ZhongkaiResult result = null;
        try {
            result = anomalyListService.verifyPass(wx_uuid,pass);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"获取失败");
        }

        return result;
    }


    /***
     * 验证密码
     * @param wx_uuid 维修用户uuid
     *
     * */
    @RequestMapping(value = "/weixiu/unit_list", produces = "application/json;charset=utf-8")
    @ResponseBody
    public ZhongkaiResult getUnitList(String wx_uuid,@RequestParam(defaultValue = "0")Integer page, @RequestParam(defaultValue = "0")Integer rows) {

        ZhongkaiResult result = null;
        try {
            result = anomalyListService.getUnitList(wx_uuid,page,rows);
        } catch (Exception e) {
            e.printStackTrace();
            return ZhongkaiResult.build(500,"获取失败");
        }

        return result;
    }
}
